/**
 * @auther yangdong
 * @create 2020-05-08
 * 工厂方法模式有一组实现了相同接口的工厂类。这样在简单工厂模式里集中在工厂方法上的压力可以由工厂方法模式里不同的工厂子类来分担。
 *
 */
public class CarTest {
    public static void main(String[] args) {
        Factory factory=new audiFactory();
        factory.getCar().run();
        Factory factory1=new bydFactory();
        factory1.getCar().run();
    }

}
interface car{
    void run();
}
class byd implements car{

    @Override
    public void run() {
        System.out.println("byd is run");
    }
}
class audi implements car{

    @Override
    public void run() {
        System.out.println("audi is run");
    }
}
interface  Factory{
    car getCar();
}
class bydFactory implements Factory{

    @Override
    public car getCar() {
        return new byd();
    }
}
class audiFactory implements Factory{

    @Override
    public car getCar() {
        return new audi();
    }
}